package com.LeeCode;

/**
 * 链表的中间结点
 */

public class Code876 {
    public static void main(String[] args) {

    }

    public ListNode middleNode(ListNode head) {
        ListNode slow = head, fast = head;
        // 后面还有节点的情况下继续走
        while (fast != null && fast.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }
        return slow;
    }
}
